package com.qidian.mes.pro.service.impl;

import com.qidian.mes.pojo.OrderBOM;
import com.qidian.mes.pojo.OrderRequire;
import com.qidian.mes.pro.mapper.BOMMapper;
import com.qidian.mes.pro.mapper.RequireMapper;
import com.qidian.mes.pro.service.MaterialBOMService;
import com.qidian.mes.pro.service.RequireService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-08 15:22
 **/
@Service
public class RequireServiceImpl implements RequireService {
    @Autowired
    private RequireMapper requireMapper;
    @Override
    public QdResult findByOrderId(Long woId) {
        return QdResult.success(requireMapper.findByWoId(woId));
    }

    @Override
    public QdResult findByRequireId(Long requireId) {
        return QdResult.success(requireMapper.findByRequireId(requireId));
    }

    @Override
    public QdResult<PagerDTO<OrderRequire>> queryPager(OrderRequire orderRequire, int start, int limit) {
        PagerDTO<OrderRequire> pagerDTO = new PagerDTO();
        pagerDTO.setPage(start);
        pagerDTO.setLimit(limit);
        pagerDTO.setTotal(requireMapper.selectCount(orderRequire));
        List<OrderRequire> list = requireMapper.queryByPage(orderRequire,(start-1)*limit,limit);
        pagerDTO.setData(list);
        return QdResult.success(pagerDTO);
    }

}
